home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: big problem with a very small program:please help me!
- Date: 11 Mar 1996 07:59 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <11MAR199607591679@erich.triumf.ca>
- References: <4hqc8p$njh@aldebaran.sct.fr>
- NNTP-Posting-Host: ftp.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4hqc8p$njh@aldebaran.sct.fr>, escali_m@worldnet.net (Marc Escalier) writes...
- >#include <stdio.h>
- >#include <math.h>
- >
- >main()
- >{
- >float i;
- >
- >i=5.25;
- >printf("i is real:l%f\n",i); /* display 5.25000000000000... ok! */
- >printf("i is integer%d\n",i); /* display 0 what does that mean ?!?*/
-
- If you lie to the compiler,, it will get it's revenge!
-
- %d tells the printf() that you are giving it an int, but you are actually
- giving it a float, (which will actually be promoted to double before printf()
- sees it). Printf() will only take as much of the float (double) as is needed
- to represent an int, and display the resulting value.
-
- >please answer by email because i don't read often comp.lang.c.
-
- This is not a write-only newsgroup - if you ask a question here, you should be
- prepared to watch for an answer here...
- >
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-
-
-
-
-
-